package com.ruoyi.web.controller.exam;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.exam.domain.PQuestionTypeEntity;
import com.ruoyi.exam.mapper.PQuestionTypeEntityMapper;
import com.ruoyi.exam.service.PQuestionTypeService;
import com.ruoyi.exam.vo.PQuestionTypeEntityVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author coldplay
 * @create 2023-10-10 15:44
 */
@RestController
@RequestMapping("/system/type")
public class QuestionTypeController {

  @Autowired
  private PQuestionTypeService pQuestionTypeService;



  @GetMapping("/getall")
  public AjaxResult getAllType(){
    List<PQuestionTypeEntity> pQuestionTypeEntities = pQuestionTypeService.selectAll();
    return AjaxResult.success(pQuestionTypeEntities);
  }

  @PostMapping("/updates")
  public AjaxResult updateTypeByIds(@RequestBody List<PQuestionTypeEntityVo> typeEntityVos){
    return pQuestionTypeService.updateByIds(typeEntityVos);
  }

  @PostMapping("/update")
  public AjaxResult updateTypeById(@RequestBody PQuestionTypeEntityVo typeEntityVo){
    return pQuestionTypeService.updateById(typeEntityVo);
  }

  @GetMapping("/delete")
  public AjaxResult deleteTypeById(@RequestParam("id") Integer id){
    return pQuestionTypeService.deleteById(id);
  }

  @GetMapping("/add")
  public AjaxResult addType(@RequestParam("name") String name,@RequestParam("type") Integer type){
    return pQuestionTypeService.addType(name,type);
  }

  @GetMapping("/getone")
  public AjaxResult getById(@RequestParam("id")Integer id){
    return pQuestionTypeService.getById(id);
  }



}
